package com.xbongbong.saas.enums.business;

import com.xbongbong.paas.constant.PaasConstant;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;
/**
 * @author wujian
 * @version v1.0
 * @date 2020/12/22 9:35
 * @since v1.0
 */
@Getter
public enum ExpressCodeEnum {

    ANNENG_KUAIDI("安能快递","ane66"),
    ANNENG_KUAIYUN("安能快运","annengwuliu"),
    DEBANG_KUAIDI("德邦快递","debangkuaidi"),
    DEBANG_WULIU("德邦物流", "debangwuliu"),
    EMS("EMS", "ems"),
    GUOTONG_KUAIDI("国通快递", "guotongkuaidi"),
    BAISHI_HUITONG("百世汇通","huitongkuaidi"),
    JINGDONG("京东","jd"),
    KUAYUE_SUYUN("跨越速运","kuayue"),
    PINJUN_KUAIDI("品骏快递","pjbest"),
    SHENTONG("申通","shentong"),
    SHUNFENG("顺丰","shunfeng"),
    SHUNFENG_FENGMIMIANDAN("顺丰（丰密面单）","shunfeng"),
    SHUNFENG_KUAIYUN("顺丰快运","shunfengkuaiyun"),
    SUER_KUAIDI("速尔快递","suer"),
    XINFENGWULIU("信丰物流","xinfengwuliu"),
    YOUSUKUAIDI("优速快递","youshuwuliu"),
    YOUZHENG_KUAIDI_BAOGUO("邮政快递包裹","youzhengguonei"),
    YUANTONG("圆通","yuantong"),
    YUANTONGGUOJI("圆通国际","yuantongguoji"),
    YUNDA("韵达","yunda"),
    ZHAIJISONG("宅急送","zhaijisong"),
    ZHONGTONG("中通","zhongtong"),
    EWE("EWE全球快递","ewe"),
    QUANYIKUAIDI("全一快递","quanyikuaidi"),
    CHENGNUODA("承诺达","ytchengnuoda"),
    WEITEPAI("微特派","weitepai"),
    TIANTIAN("天天","tiantian"),
    LONGBANGWULIU("龙邦物流","lbex"),
    DSUKUAIDI("D速快递","dsukuaidi"),
    YINYANZHUANSONG("银雁专送","cfss"),
    JITUSUDI("极兔速递","jtexpress"),
    HUISENSUYUN("汇森速运","huisenky"),
    ZHONGYOUKUAIDI("众邮快递","zhongyouex"),
    JIAYUNMEISUDI("加运美速递","jym56"),
    DAMALU("大马鹿","idamalu"),
    ;


    /**
     * 快递公司名称
     */
    private String expressName;

    /**
     * 快递公司编码
     */
    private String expressCode;

    ExpressCodeEnum(String expressName, String expressCode) {
        this.expressName = expressName;
        this.expressCode = expressCode;
    }


    /**
     * 获取所有快递名称及对应的快递编码
     * @return
     */
    public static Map<String, String>  getAllEnum(){
        Map<String, String> expressCodeMap = new HashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);
        for (ExpressCodeEnum value : values()) {
            expressCodeMap.put(value.expressName, value.expressCode);
        }
        return expressCodeMap;
    }

    /**
     * 根据快递名称获取对应的快递编码
     */
    public static String  getCodeByExpressname(String expressName){
        for (ExpressCodeEnum value : values()) {
            if (value.expressName.equals(expressName)){
                return value.expressCode;
            }
        }
        return expressName;
    }

    /**
     * 根据快递编码获取对应快递名称
     */
    public static String getExpressNameByCode(String code){
        for (ExpressCodeEnum value : values()) {
            if (value.expressCode.equals(code)){
                return value.expressName;
            }
        }
        return code;
    }

    /**
     * 是否存在此快递编码
     */
    public static boolean hasExpressCode(String code){
        for (ExpressCodeEnum value : values()) {
            if (value.expressCode.equals(code)){
                return true;
            }
        }
        return false;
    }
}

